#ifndef __RGB_H
#define __RGB_H

#include "stm32f10x.h"


// 初始化时钟
#define led_clk_enable() { RCC->APB2ENR |= 0x1 << (4 * 1); }  // GPIOC初始化


#define led_r(x)   x ? (GPIOC->BSRR |= 1 << 8) : (GPIOC->BRR |= 1 << 8)
#define led_g(x)   x ? (GPIOC->BSRR |= 1 << 7) : (GPIOC->BRR |= 1 << 7)
#define led_b(x)   x ? (GPIOC->BSRR |= 1 << 6) : (GPIOC->BRR |= 1 << 6)
                            
// LED 端口
#define led_port GPIOC
#define led_r_pin GPIO_Pin_8
#define led_g_pin GPIO_Pin_7
#define led_b_pin GPIO_Pin_6

// rgb颜色
typedef enum
{
    black = 0, //000
    blue, // 001
    green,// 010
    lblue, // 011
    red, // 100
    purple, // 101
    lgreen, // 110
    white //111
}color;


void rgb_led_init(void);
void rgb_toggle(void);
void set_rgb(color rgb);

#endif
